package ${basePackage}.controller.${module};

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.unswift.annotation.api.Api;
import com.unswift.annotation.api.ApiField;
import com.unswift.annotation.api.ApiMethod;
import ${basePackage}.annotation.LockException;
import ${basePackage}.annotation.request.Auth;
import ${basePackage}.controller.BaseController;
import ${basePackage}.pojo.vo.ResponseBody;
import ${basePackage}.pojo.bo.${module}.${currModule}.${entityName}ExportBo;
import ${basePackage}.pojo.bo.${module}.${currModule}.${entityName}ExportStopBo;
<#if stringUtils.contains(dataOperator,'import',',')>
import ${basePackage}.pojo.bo.${module}.${currModule}.${entityName}ImportBo;
import ${basePackage}.pojo.bo.${module}.${currModule}.${entityName}ImportStopBo;
</#if>
import ${basePackage}.pojo.dto.${module}.${currModule}.${entityName}ExportDto;
import ${basePackage}.pojo.dto.${module}.${currModule}.${entityName}ExportStopDto;
<#if stringUtils.contains(dataOperator,'import',',')>
import ${basePackage}.pojo.dto.${module}.${currModule}.${entityName}ImportDto;
import ${basePackage}.pojo.dto.${module}.${currModule}.${entityName}ImportStopDto;
</#if>
import ${basePackage}.pojo.vo.${module}.${currModule}.${entityName}ExportVo;
import ${basePackage}.pojo.vo.${module}.${currModule}.${entityName}ExportStopVo;
<#if stringUtils.contains(dataOperator,'import',',')>
import ${basePackage}.pojo.vo.${module}.${currModule}.${entityName}ImportVo;
import ${basePackage}.pojo.vo.${module}.${currModule}.${entityName}ImportStopVo;
</#if>
import ${basePackage}.service.export.${module}.${entityName}ExportService;
<#if stringUtils.contains(dataOperator,'import',',')>
import ${basePackage}.service.imports.${module}.${entityName}ImportService;
</#if>

@RestController
@RequestMapping("/${entitySampleName}")
@Api(value="${tableComment}对外接口", author="${username}", date="${date}", version="1.0.0")
public class ${entityName}ImexportController extends BaseController{
	
	@Autowired
	@ApiField("${tableComment}导出服务")
	private ${entityName}ExportService ${entitySampleName}ExportService;
	<#if stringUtils.contains(dataOperator,'import',',')>
	
	@Autowired
	@ApiField("${tableComment}导入服务")
	private ${entityName}ImportService ${entitySampleName}ImportService;
	</#if>
	
	@Auth("${module}.${currModule}.export")
	@RequestMapping(value="/export", method=RequestMethod.POST)
	@LockException(prefix = "${entitySampleName}Export", unique = "{currUserId}", messageCode = "task.is.currently.executing", messageArgs = "有${tableComment}导出")
	@ApiMethod(value="导出${tableComment}", params=@ApiField("导出条件实体"), returns=@ApiField("导出结果Vo->id:任务id,result:{0：未创建，1：已创建}"))
	public ResponseBody<${entityName}ExportVo> export(@RequestBody ${entityName}ExportDto exportDto){
		${entityName}ExportBo exportBo=this.convertPojo(exportDto, ${entityName}ExportBo.class);//将Dto转换为Bo
		return ResponseBody.success(${entitySampleName}ExportService.export(exportBo));
	}
	
	@Auth("${module}.${currModule}.export")
	@RequestMapping(value="/export/stop", method=RequestMethod.POST)
	@ApiMethod(value="停止导出${tableComment}", params=@ApiField("停止对象"), returns=@ApiField("停止结果Vo->result:{0：未停止，1：已停止}"))
	public ResponseBody<${entityName}ExportStopVo> exportStop(@RequestBody ${entityName}ExportStopDto exportStopDto){
		${entityName}ExportStopBo exportStopBo=this.convertPojo(exportStopDto, ${entityName}ExportStopBo.class);//将Dto转换为Bo
		return ResponseBody.success(${entitySampleName}ExportService.stop(exportStopBo));
	}
	<#if stringUtils.contains(dataOperator,'import',',')>
	
	@Auth("${module}.${currModule}.import")
	@RequestMapping(value="/import", method=RequestMethod.POST)
	@LockException(prefix = "${entitySampleName}Import", unique = "{currUserId}", messageCode = "task.is.currently.executing", messageArgs = "有${tableComment}导入")
	@ApiMethod(value="导入${tableComment}", params=@ApiField("导入实体"), returns=@ApiField("导入结果Vo->id:任务id,result:{0：未导入，1：已导入}"))
	public ResponseBody<${entityName}ImportVo> imports(@RequestBody ${entityName}ImportDto importDto){
		${entityName}ImportBo importBo=this.convertPojo(importDto, ${entityName}ImportBo.class);//将Dto转换为Bo
		return ResponseBody.success(${entitySampleName}ImportService.imports(importBo));
	}
	
	@Auth("${module}.${currModule}.import")
	@RequestMapping(value="/import/stop", method=RequestMethod.POST)
	@ApiMethod(value="停止导入${tableComment}", params=@ApiField("停止对象"), returns=@ApiField("停止结果Vo->result:{0：未停止，1：已停止}"))
	public ResponseBody<${entityName}ImportStopVo> importStop(@RequestBody ${entityName}ImportStopDto importStopDto){
		${entityName}ImportStopBo importStopBo=this.convertPojo(importStopDto, ${entityName}ImportStopBo.class);//将Dto转换为Bo
		return ResponseBody.success(${entitySampleName}ImportService.stop(importStopBo));
	}
	</#if>
}